package com.my.system.controller;

import com.my.response.Result;
import com.my.system.entity.SysDept;
import com.my.system.entity.domain.*;
import com.my.system.service.ISysDeptService;
import com.my.system.service.impl.SysDeptService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 部门表 前端控制器
 * </p>
 *
 * @author my
 * @since 2021-04-21
 */
@RestController
@RequestMapping("/system/dept")
@Api(value = "系统管理模块", tags = "部门接口")
public class SysDeptController {

    private ISysDeptService deptService;

    public SysDeptController(SysDeptService deptService) {
        this.deptService = deptService;
    }

    @GetMapping("/treeDeptList")
    @ApiOperation("部门下拉树列表")
    public Result treeDeptList(SysDept dept) {
        List<SysDept> depts = deptService.selectDeptList(dept);
        List<TreeSelect> deptTreeList = null;
        if (depts.size() > 0) {
            deptTreeList = deptService.buildDeptTreeSelect(depts);
        }
        return Result.ok("").data("deptTreeList", deptTreeList);
    }
}

